package test;

import com.swotxu.tx.TxConfig;
import com.swotxu.tx.service.UserService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTest_tx {

	public AnnotationConfigApplicationContext context;
	@Before
    public void befor() {
        context = new AnnotationConfigApplicationContext(TxConfig.class);
        System.out.println("容器创建完成。。");

    }
    private void printBeans(AnnotationConfigApplicationContext context) {
        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
    }
    @Test
    public void test01() {
        printBeans(context);

        System.out.println("==============");
        UserService service = context.getBean(UserService.class);
        service.insert();

        System.out.println("=======容器关闭=======");
        context.close();
    }
}
